#ifndef SORTEDBUFFERMANAGER_H
#define SORTEDBUFFERMANAGER_H

#include "BufferManager.h"
#include <list>

class SortedBufferManager : public BufferManager
{
public:
    SortedBufferManager(const SortedBufferManager& other) = delete;
    SortedBufferManager operator=(const SortedBufferManager& other) = delete;

    BufferFrame& getPage(unsigned pageId, bool exclusive);
    virtual ~SortedBufferManager();

protected:
    SortedBufferManager(const std::string& filename, unsigned size);

    unsigned flushPages;
    SEMAPHORE freeQueueSemaphore;

    virtual int swapPage();
    virtual void writeToDisk(list<BufferFrame*>& frame);
    virtual void sortPages(list<BufferFrame*>& pageList);

private:

    friend class DB;
};

#endif // BUFFERMANAGER_H
